﻿@using Partner.Surround.Admin.Views
@using Partner.Surround.Admin.Views.Shared.Components.RightNavbarUserArea
@using Partner.Surround.Admin.Views.Shared.Components.SideBarMenu
@{
    ViewBag.Title = L("HomePage");
    ViewBag.CurrentPageName = SurroundPageName.Home;
}

@await Component.InvokeAsync(typeof(SideBarMenuViewComponent))

<nav class="mui-bar mui-bar-tab">
    <a id="defaultTab" class="mui-tab-item mui-active" href="@Url.Action("Index","Home")">
        <span class="mui-icon mui-icon-home"></span>
        <span class="mui-tab-label">首页</span>
    </a>
    <a class="mui-tab-item" href="@Url.Action(!AbpSession.TenantId.HasValue ? "HostConsole": "TenantConsole", "WorkSpace")">
        <span class="mui-icon mui-icon-checkbox"></span>
        <span class="mui-tab-label">工作台</span>
    </a>
    <a class="mui-tab-item" href="@Url.Action("Logout","Account")">
        <span class="mui-icon mui-icon-email"></span>
        <span class="mui-tab-label">退出</span>
    </a>
    <a class="mui-tab-item" href="@Url.Action("UserProfile","Users")">
        <span class="mui-icon mui-icon-person"></span>
        <span class="mui-tab-label">我的</span>
    </a>
</nav>

@section scripts{
    <script type="text/javascript">
        mui.init({

        });

        var subpages = [
            '@Url.Action("Index","Home")',
            '@Url.Action(!AbpSession.TenantId.HasValue ? "HostConsole": "TenantConsole", "WorkSpace")',
            '@Url.Action("Logout","Account")',
            '@Url.Action("UserProfile","Users")'
        ];

        var subpage_style = {
            top: '44px',
            bottom: '50px'
        };

        var activeTab = subpages[0];

        mui.plusReady(function () {
            var self = plus.webview.currentWebview();

            for (var i = 0; i < subpages.length; i++) {
                var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
                if (i > 0) {
                    sub.hide();
                }
                self.append(sub);
            }

            plus.webview.show(activeTab);

            mui('.mui-bar-tab').on('tap', 'a', function (e) {
                var targetTab = this.getAttribute('href');
                if (targetTab == activeTab) {
                    return;
                }

                plus.webview.show(targetTab, "fade-in", 300);
                plus.webview.hide(activeTab);
                activeTab = targetTab;
            });
        });
    </script>
}
